#!/usr/bin/env bash

if [[ -z $ZSH_CUSTOM ]]; then
    export ZSH_CUSTOM="${ZSH:-~/.oh-my-zsh}/custom"
fi

mkdir -p "$ZSH_CUSTOM/plugins" || exit 1
pushd "$ZSH_CUSTOM/plugins" || exit 1

repos=(
    # https://github.com/zsh-users/zsh-autosuggestions

    # from https://github.com/zchee/zsh-completions.git
    https://gitcode.com/gh_mirrors/zsh/zsh-completions.git

    # from https://github.com/zsh-users/zsh-syntax-highlighting.gt
    # https://gitee.com/mirrors/zsh-syntax-highlighting.git
    https://gitcode.com/gh_mirrors/zs/zsh-syntax-highlighting.git

    # from https://github.com/marzocchi/zsh-notify.git
    https://gitcode.com/gh_mirrors/zs/zsh-notify.git
)

for url in "${repos[@]}"; do
    git clone --depth=1 --single-branch "$url"
    if [[ $? != 0 ]]; then
        echo -e "\e[31mFailed to clone $url\e[0m"
    fi
done
